﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Mvc;
using System.Web.Routing;

namespace Ic.Web.Controllers.Band
{
    public class BandArea : AreaRegistration
    {
        public override string AreaName
        {
            get { return "Band";}
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            AreaHelper.MapRouteAdd(context, "Demo_default", "Band/{controller}/{action}/{id}",
                "Demo", "Index", "");
            AreaHelper.MapRouteAdd(context, "Data_default", "Band/{controller}/{action}/{id}",
                "Data", "Index", "");
        }
    }

}

namespace Ic.Web.Controllers.News
{
    public class NewsArea : AreaRegistration
    {
        public override string AreaName
        {
            get { return "News"; }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            AreaHelper.MapRouteAdd(context, "News_default", "News/{controller}/{action}/{id}",
               "Home", "Index", "");           
        }
    }
}

/// <summary>
/// 扩展AreaRegistration
/// 注册路由表助手
/// </summary>
public static class AreaHelper
{
    public static void MapRouteAdd(AreaRegistrationContext context,
        string routeName, string routePath, string controllerName, string actionName, string idName)
    {
        if (context.Routes[routeName] == null) {
            context.MapRoute(routeName,routePath,
                new { controller = controllerName, action =actionName, id = idName });
        }
    }
}


